package com.toe.commodity.webapi.controller;


import com.toe.commodity.webapi.service.impl.CommodityGoodsTypeServiceImpl;
import com.toe.common.restful.JsonResult;
import com.toe.pojo.entity.commodity.CommodityGoodsType;
import com.toe.pojo.vo.commodity.CommodityGoodsTypeVO;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 陶涛
 * @since 2022-07-19
 */
@RestController
@RequestMapping("/webapi/commodity-goods-type")
public class CommodityGoodsTypeController {

    @Autowired
    CommodityGoodsTypeServiceImpl commodityGoodsTypeService;

    @GetMapping("/getCommodityGoodsType")
    @ApiOperation("查询商品类型")
    public JsonResult getCommodityGoodsType(){
       List<CommodityGoodsTypeVO> commodityGoodsType = commodityGoodsTypeService.getCommodityGoodsType();
        return JsonResult.ok("查询成功",commodityGoodsType);
    }

    @GetMapping("/addNewCommodityGoodsType")
    @ApiOperation("新增商品类型")
    public JsonResult addNewCommodityGoodsType(String GoodsTypeName){
        commodityGoodsTypeService.addNewCommodityGoodsType(GoodsTypeName);
        return JsonResult.ok("新增成功");
    }

    @GetMapping("/deletedCommodityGoodsType/{id}")
    @ApiOperation("删除商品类型")
    public JsonResult deletedCommodityGoodsType(@PathVariable("id") Long id){
        commodityGoodsTypeService.deletedCommodityGoodsType(id);
        return  JsonResult.ok("删除成功");
    }

    @GetMapping("/updateCommodityGoodsTypeName")
    @ApiOperation("修改商品类型")
    public JsonResult updateCommodityGoodsTypeName(CommodityGoodsType commodityGoodsType){
        commodityGoodsTypeService.updateCommodityGoodsTypeName(commodityGoodsType);
        return JsonResult.ok("修改完成");
    }
}

